<template>
	<view>

		<template v-if='loading'>
			<view v-for="(item,index) in 5" :key="index">
				<view class=" Skeleton" style="height: 30rpx;" />
				<view class="activeContent" style="border: none;">
					<view>
						<album :loading='loading' />
					</view>
					<view class=" Skeleton" style="height: 30rpx;margin-top: 20rpx;" />
				</view>
			</view>
		</template>
		<template v-else>
			<view class="activeBox" v-for="(item,index) in active" :key="index">
				<view class="created_at">
					<u-avatar :src='item.customer.avatar' size='80rpx'  @click='jumpCustomer(item.decorates)'/>
					<view style="margin:0 10rpx;flex: 1;">
						<u-text lines='1' :text='item.decorates.remark_name' size='24rpx' />
						<u-text lines='1' :text='item.customer.nick_name' size='24rpx' color='#999' />
					</view>
					<text>{{item.created_at | changeTime}}</text>
				</view>
				<view class="activeContent">
					<view class="content">
						<view style="margin: 10rpx 0;">
							<u-parse :content="item.title"></u-parse>
						</view>
						<view class="albumBox" v-if="item.images.length||item.videos.length">
							<view class="process">
								{{item.process.title}}
							</view>
							<album :ref='`album${index}`' :imageList='item.images'
								:video='item.videos.map(imageItem=>imageItem.url)' :index='index'
								:playIndex='playIndex' />
						</view>

						<view class="userBox">
							<u-avatar :src='item.user.avatar' size='60rpx' />
							<view>
								<u-text :lines='1' :text='item.user.nick_name' size='24rpx' />
								<u-text :lines='1' :text='item.decorates.district' prefixIcon='map' size='24rpx'
									color='#999' />
							</view>
						</view>
					</view>
				</view>
			</view>
		</template>

	</view>
</template>

<script>
	import album from '@/components/album.vue';
	export default {
		components: {
			album,
		},
		props: ['loading', 'active', 'playIndex'],
		data() {
			return {
				userInfo: uni.getStorageSync('user'),
			}
		},
		methods: {
			jumpCustomer(item){
				if(this.userInfo?.is_company_administrator){
					this.$utils.navigateTo({
						url: '/customer_company/detail?id=' + item.id
					})
				}else{
					this.$utils.navigateTo({
						url: '/customer/detail_c?id=' + item.id
					})
				}
			}

		}
	}
</script>

<style lang="scss" scoped>
	.created_at {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		margin-right: 40rpx;
		align-items: center;
	}

	.activeContent {
		padding: 0 0 0 45rpx;
		margin: 10rpx 0 10rpx 35rpx;
		border-left: 1rpx dashed #bbb;

		>.content {
			box-shadow: 0 0 10rpx #ddd;
			margin-right: 30rpx;
			padding: 20rpx;
			border-radius: 8rpx;
			background-color: #fff;
		}
	}

	.operationBox {
		display: flex;
		justify-content: flex-end;
	}

	.userBox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 20rpx 0;

		view:nth-child(2) {
			flex: 0.98;
		}
	}

	.iconBox {
		display: flex;
		justify-content: space-between;
		width: 100%;
		margin-bottom: 20rpx;

		>view:nth-child(1) {
			flex: 1;
			margin-right: 10rpx;
		}
	}

	.albumBox {
		position: relative;
	}

	.process {
		position: absolute;
		z-index: 11;
		padding: 10rpx 20rpx;
		background: rgba(0, 0, 0, 0.3);
		top: 20rpx;
		left: 20rpx;
		color: #fff;
		border-radius: 8rpx;
	}
</style>